#define _CRT_SECURE_NO_WARNINGS
#include<vector>
#include<string>
using namespace std;
int numDistinct(string s, string t) {
    int n = s.size();
    int m = t.size();
    if (n < m)return 0;
    vector<vector<unsigned long long>> dp(n + 1, vector<unsigned long long>(m + 1));
    for (int j = 0; j <= m; j++) {
        dp[0][j] = 0;
    }
    for (int i = 0; i <= n; i++) {
        dp[i][0] = 1;
    }

    s = '_' + s;
    t = "_" + t;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (s[i] == t[j])
                dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
            else
                dp[i][j] = dp[i - 1][j];
        }
    }
    return dp[n][m];
}